<template>
  <div class="form-single-fragment" style="position: relative;">
    <h3>查看</h3>
    <el-form :model="ruleForm" ref="ruleForm" label-width="180px" size="mini" label-position="right">
      <el-row :gutter="20" class="form-single-info">
        <el-col :span="20">
          <div class="title"><h4>项目信息</h4></div>
          <el-row>
            <el-col :span="12">
              <el-form-item label="项目名称：">{{detailData.projectName || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="项目编号：">{{detailData.projectCode || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="所在地区：">{{detailData.areaName || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="合同金额（元）：">{{detailData.contractAmount || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="单位名称：">{{detailData.customerName || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="业务类型：">{{detailData.businessTypeName || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="合同签约时间：">{{detailData.signingDate || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="合同完成时间：">{{detailData.finishDate || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="实际完成时间：">{{detailData.finishDate || '--'}}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="项目状态：">{{detailData.projectStatusName || '--'}}</el-form-item>
            </el-col>
          </el-row>
          <div class="title">
            <h4>成员评分</h4>
          </div>
          <el-table :data="ruleForm.personalScoreDoList" size="mini" style="width: 100%;" header-cell-class-name="table-header-gray">
            <el-table-column type="index" align="center" width="55" label="序号"></el-table-column>
            <el-table-column prop="userName" align="center" label="姓名"></el-table-column>
            <el-table-column prop="deptName" align="center" label="部门"></el-table-column>
            <el-table-column prop="postName" align="center" label="岗位"></el-table-column>
            <el-table-column prop="score" align="center" label="评分"></el-table-column>
          </el-table>
          <div class="title info">
            <span>评分说明：<br/>
            根据项目成员在项目中发挥的实际贡献情况进行评分，所有成员评分合计为100分。</span>
          </div>
        </el-col>
      </el-row>
      <el-form-item style="padding: 20px 0;">
        <el-button size="mini" @click="resetForm">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { Administration, Contracts } from '@/api/projectAdministration.js';
import { Personalintergral } from '@/api/integrals.js';
export default {
  name: 'PersonalintergralEdit',
  data () {
    return {
      loading: false,
      isShowloading: false,
      areaCodes: [],
      areaCodelist: [],
      areaCodeprops: {
        label: 'name',
        value: 'id',
        children: 'children',
        checkStrictly: true
      },
      customerlist: [],
      detailData: {},
      tableData: [],
      ruleForm: {}
    };
  },
  created () {
    this.loadProjectDetailWidgetData()
    this.loadUserWidgetData()
  },
  methods: {
    /**
    * 项目详情
    */
    loadProjectDetailWidgetData () {
      let params = {
        id: this.$route.query.projectId
      };
      return new Promise((resolve, reject) => {
        Administration.detail(this, params).then(res => {
          this.detailData = res.data
          if (this.detailData.contractId) {
            this.loadContractDetailWidgetData()
          }
        }).catch(e => {
          reject(e);
        });
      });
    },
    /**
    * 合同简介
    */
    loadContractDetailWidgetData () {
      let params = {
        id: this.detailData.contractId
      };
      return new Promise((resolve, reject) => {
        Contracts.detail(this, params).then(res => {
          this.detailData.contractAmount = res.data.contractAmount
          this.detailData.signingDate = res.data.signingDate
          this.detailData.finishDate = res.data.finishDate
        }).catch(e => {
          reject(e);
        });
      });
    },
    /**
     * 项目成员列表
     */
    loadUserWidgetData () {
      let params = {
        deptId: this.$route.query.deptId,
        projectId: this.$route.query.projectId
      }
      return new Promise((resolve, reject) => {
        Personalintergral.list(this, params).then(res => {
          this.ruleForm.personalScoreDoList = res.data.records
          this.$forceUpdate()
        }).catch(e => {
          reject(e);
        });
      });
    },
    resetForm () {
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="scss" scoped>
h3{border-bottom: 1px solid #E9E9EB;padding: 0 0 10px;}
.table_container{margin: 10px 0;}
.form-single-info{display: flex;justify-content: center;}
.el-form-info{box-shadow: 0 0 10px rgba(0,0,0,0.05);padding: 20px;}
.el-form-info strong{margin: 0 10px;}
.el-form-info .el-time-picker{width: 100%;}
.title{
  display: flex;align-items: center;justify-content: space-between;
  h4{font-weight: bold;}
}
.info{margin: 10px 0;line-height: 24px;}
</style>
